package uniLearn.data;

/**
 * @author ttw1988
 *	Class Name: uniLearn.data.user
 *  usage: data of the user in UniLearn
 */
public class Users {
	//define
	public static final int ID_MAX_LENGTH = 20;
	public static final int NAME_MAX_LENGTH = 50;
	
	//variable
	private String id;
	private String name;
	private UsersType userType;
	
	//constructor
	public Users(String id, String name, UsersType userType) {
		if(id.isEmpty() || id.length() > 20) { 
			//error
		}
		else if(name.isEmpty() || name.length() > 50) {
			//error
		}
		
		this.id = id;
		this.name = name;
		this.userType = userType;
	}
	
	public String getId() {
		return id;
	}
	public String getName() {
		return name;
	}
	public UsersType getUserType() {
		return userType;
	}
	
	//override method
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result
				+ ((userType == null) ? 0 : userType.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Users other = (Users) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (userType != other.userType)
			return false;
		return true;
	}
	@Override
	public String toString() {
		return "user [id=" + id + ", name=" + name + ", userType=" + userType
				+ "]";
	}
}
